package org.micode.demo.web.interceptor;

import org.micode.common.domain.base.IUserCache;
import org.micode.libs.servlet.interceptor.CommonWebInterceptor;
import org.micode.demo.db.cache.user.ISysUserCacheHandler;
import org.micode.demo.db.cache.user.SysUserCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class WebAdminInterceptor extends CommonWebInterceptor {

    @Autowired
    private ISysUserCacheHandler sysUserCacheHandler;

    @Override
    protected boolean checkPermissionsFlag(String permissionsFlagValue, IUserCache userAuthCache) {
        return true;
    }

    @Override
    protected void setUserCacheByToken(String token, String clientApp, IUserCache userAuth) {
        sysUserCacheHandler.setByKey(token, (SysUserCache) userAuth);
    }

    @Override
    protected SysUserCache getUserCacheByToken(String token, String clientApp) {
        return sysUserCacheHandler.getByKey(token);
    }

    @Override
    protected void updateUserActive(Long userId, String clientApp) {
        // 用户激活的处理
    }

}
